home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / BEERSRC.ZIP / MOUSEASM.ASM < prev    next >
Encoding:
Assembly Source File  |  1991-05-14  |  5.0 KB  |  198 lines

  1. ;---------------------------------------------------------;
  2. ;                                                         ;
  3. ;                    M O U S E . A S M                    ;
  4. ;                                                         ;
  5. ;                                                         ;
  6. ;           [c] Copyright by Dany Schoch 1989             ;
  7. ;                                                         ;
  8. ;---------------------------------------------------------;
  9.  
  10.  
  11.  
  12.     .model  compact, c
  13.  
  14.  
  15.  
  16. IF      @DataSize
  17.  
  18. LES_            equ     LES
  19. ES_             equ     ES:
  20. SS_             equ     SS:
  21. LDS_            equ     LDS
  22.  
  23. ELSE
  24.  
  25. LES_            equ     MOV
  26. ES_             equ     DS:
  27. SS_             equ     DS:
  28. LDS_            equ     MOV
  29.  
  30. ENDIF
  31.  
  32.  
  33. Mouse           equ     33h
  34.  
  35.  
  36.         .data
  37.  
  38. eventofs        dw      ?               ; pointer to event-handler
  39. eventseg        dw      ?               ;
  40.  
  41.  
  42.  
  43.         .code
  44.  
  45.  
  46.     public    m_deviceinit
  47. m_deviceinit    proc    state :ptr word, buttons :ptr word
  48.  
  49.         mov     ax, 0000h               ; function 00h
  50.         int     Mouse                   ; call Mouse functions
  51.         LES_    di, buttons             ; get address of buttons
  52.         mov     ES_[di], bx             ; *Buttons=bx
  53.         LES_    di, state               ; get address of state
  54.         mov     ES_[di], ax             ; *state=ax
  55.         ret                             ;
  56.  
  57. m_deviceinit    endp
  58.  
  59.  
  60.     public    m_showcursor
  61. m_showcursor    proc
  62.  
  63.         mov     ax, 0001h               ; function 01h
  64.         int     Mouse                   ; call Mouse functions
  65.         ret                             ; return
  66.  
  67. m_showcursor    endp
  68.  
  69.  
  70.     public    m_hidecursor
  71. m_hidecursor    proc
  72.  
  73.         mov     ax, 0002h               ; function 02h
  74.         int     Mouse                   ; call Mouse functions
  75.         ret                             ; return
  76.  
  77. m_hidecursor    endp
  78.  
  79.  
  80.     public    m_getpos
  81. m_getpos        proc    b :ptr word, x :ptr word, y :ptr word
  82.  
  83.         mov     ax, 0003h               ; function 03h
  84.         int     Mouse                   ; call Mouse functions
  85.         LES_    di, y                   ; get address of y
  86.         mov     ES_[di], dx             ; *y=dx
  87.         LES_    di, x                   ; get address of x
  88.         mov     ES_[di], cx             ; *x=cx
  89.         LES_    di, b                   ; get address of Button
  90.         mov     ES_[di], bx             ; *Button=bx
  91.         ret                             ;
  92.  
  93. m_getpos        endp
  94.  
  95.  
  96.     public    m_setpos
  97. m_setpos        proc    x :word, y :word
  98.  
  99.         mov     ax, 0004h               ; function 04h
  100.         mov     dx, y                   ; dx=y
  101.         mov     cx, x                   ; cx=x
  102.         int     Mouse                   ; call Mouse functions
  103.         ret                             ;
  104.  
  105. m_setpos        endp
  106.  
  107.  
  108.  
  109.     public    m_setxborder
  110. m_setxborder    proc    x1 :word, x2 :word
  111.  
  112.         mov     ax, 0007h               ; function 07h
  113.         mov     dx, x2                  ; dx=x2  (max x position)
  114.         mov     cx, x1                  ; cx=x1  (min x position)
  115.         int     Mouse                   ; call Mouse functions
  116.         ret                             ;
  117.  
  118. m_setxborder    endp
  119.  
  120.  
  121.  
  122.     public    m_setyborder
  123. m_setyborder    proc    y1 :word, y2 :word
  124.  
  125.         mov     ax, 0008h               ; function 08h
  126.         mov     dx, y2                  ; dx=y2  (max y position)
  127.         mov     cx, y1                  ; cx=y1  (min y position)
  128.         int     Mouse                   ; call Mouse function
  129.         ret
  130.  
  131. m_setyborder    endp
  132.  
  133.  
  134. _privhdlr       proc    far
  135.  
  136.         push    ax
  137.         push    bx
  138.         push    cx
  139.         push    dx
  140.         push    es
  141.         push    ds
  142.         push    si
  143.         push    di
  144.         push    bp
  145.         mov     bp,DGROUP
  146.         mov     ds,bp
  147.  
  148.         call    dword ptr eventofs
  149.  
  150.         pop     bp
  151.         pop     di
  152.         pop     si
  153.         pop     ds
  154.         pop     es
  155.         pop     dx
  156.         pop     cx
  157.         pop     bx
  158.         pop     ax
  159.         ret
  160.  
  161. _privhdlr       endp
  162.  
  163.  
  164.     public    m_seteventhdlr
  165. m_seteventhdlr  proc    hdlr :far ptr, maskbits :word
  166.  
  167.         mov     ax, 000ch               ; function 0ch
  168.         mov     cx, maskbits            ;
  169.         les     dx, hdlr                ; es:dx = pointer to subroutine
  170.         mov     eventseg, es            ;
  171.         mov     eventofs, dx            ;
  172.         push    cs                      ;
  173.         pop     es                      ; set up pointer to _privhdlr
  174.         lea     dx, cs:_privhdlr        ;
  175.         int     Mouse                   ;
  176.         ret                             ;
  177.  
  178. m_seteventhdlr  endp
  179.  
  180.  
  181.     public    m_definecursor
  182. m_definecursor  proc    x :word, y :word, shape :far ptr
  183.  
  184.         mov     ax, 0009h
  185.         mov     bx, x
  186.         mov     cx, y
  187.         les     dx, shape
  188.  
  189.         int     Mouse
  190.  
  191.         ret
  192.  
  193. m_definecursor  endp
  194.  
  195.  
  196.         end
  197.  
  198.